import React, { Component } from 'react'
import {
  Col,
  Button,
  Table,
  Space,
  Row,
  Form,
  message,
  Tooltip,
  Input,
  Tabs,
  DatePicker,
  Radio,
  Tag,
  Upload,
  Select,
} from 'antd'
import {
  EditOutlined,
  PlusOutlined,
  DeleteFilled,
  UploadOutlined,
  DownloadOutlined,
  InboxOutlined,
} from '@ant-design/icons'
import 'antd/dist/antd.css'

import {
  searchReviewData,
  searchHistoryReviewData,
  addReviewData,
  deleteReviewData,
  executeReviewData,
  assignReviewData,
  planEndTimeReviewData,
  publishReviewData,
  exportReviewData,
  downloadImportReviewModal,
  searchMyReviewData,
  // searchExpert,
  searchExpertList,
} from '../../api2'
import { confirmDeptByCode } from '../../utils/index.js'
import moment from 'moment'
import 'moment/locale/zh-cn'
import AdvancedSearchForm from '../../componentJsx/common/searchForm'
import HasPermi from '../../componentJsx/common/hasPermi'
import NewModal from '../../componentJsx/common/NewModal'
import '../../componentCss/component.css'
import './index.css'
//字典
import {
  getDictionaryLabel,
  getAjaxurl,
} from '../../rudexRou/OperatesCookie.js'

class Index extends Component {
  constructor(props) {
    super(props)
    this.state = {
      reviewEmpList: [],
      bottonListLeft: [
        {
          interceptor: 'tmfs:review:add',
          type: 'primary',
          clickFn: () => this.showModal('add'),
          icon: <PlusOutlined />,
          text: '创建评定任务',
        },
        {
          interceptor: 'tmfs:review:del',
          type: 'danger',
          clickFn: () => this.showModal('delete'),
          text: '删除评定任务',
        },
        {
          interceptor: 'tmfs:review:assign',
          type: 'ghost',
          clickFn: () => this.showModal('setEmp'),
          text: '设置评定人',
        },
        {
          interceptor: 'tmfs:review:planCompleteDate',
          type: 'ghost',
          clickFn: () => this.showModal('setTime'),
          text: '设置评定完成时间',
        },
        {
          interceptor: 'tmfs:review:publishStatus',
          type: 'ghost',
          clickFn: () => this.showModal('publish'),
          text: '设置发布状态',
        },
      ],
      // bottonListMiddle: [
      //   {
      //     interceptor: 'tmfs:review:edit',
      //     type: 'ghost',
      //     clickFn: () => this.showModal('perform', 0),
      //     text: '执行评定',
      //   },
      //   {
      //     interceptor: 'tmfs:review:publishStatus',
      //     type: 'ghost',
      //     clickFn: () => this.showModal('publish'),
      //     text: '设置发布状态',
      //   },
      // ],
      bottonListMy: [
        {
          interceptor: 'tmfs:review:edit',
          type: 'ghost',
          clickFn: () => this.showModal('perform'),
          text: '执行评定',
        },
      ],
      bottonListRight: [
        {
          interceptor: 'tmfs:review:import',
          clickFn: () => this.showModal('upload'),
          icon: <UploadOutlined />,
          text: '导入',
        },
        {
          interceptor: 'tmfs:review:export',
          clickFn: () => this.showModal('download', 0),
          icon: <DownloadOutlined />,
          text: '导出',
        },
      ],
      addModalVisible: false, //新增的模态框
      deleteModalVisible: false, //删除的模态框
      setEmpModalVisible: false, //设置评定人模态框
      setTimeModalVisible: false, //设置评定时间
      performModalVisible: false, //执行评定
      publishModalVisible: false, //发布评定
      downloadModalVisible: false, //导出
      uploadModalVisible: false, //导入
      publishStatus: 0,
      file: null, //文件上传
      fileList: [],
      downState: null,
      confirmLoading: false, //确认按钮异步等待
      lastLoading: false, //表格等待
      historyLoading: false, //表格等待
      myLoading: false,
      selectedRowKeys: [], //最新表格多选
      selectedRows: [],
      selectedRowKeysHistory: [], //历史表格多选
      selectedRowsHistory: [],
      selectedRowsMy: [],
      selectedRowKeysMy: [],
      selectedRowsAdd: [], //添加表格多选
      selectedRowKeysAdd: [],
      //创建评定的表格列
      addColumns: [
        {
          title: '工号',
          dataIndex: 'empNo',
          key: 'empNo',
          fixed: 'left',
          width: 80,
          ellipsis: true,
        },
        {
          title: '姓名',
          dataIndex: 'empName',
          key: 'empName',
          fixed: 'left',
          ellipsis: true,
          width: 120,
        },
        {
          title: '地域',
          dataIndex: 'regional',
          key: 'regional',
          ellipsis: true,
          width: 100,
        },
        {
          title: '部门CU',
          dataIndex: 'departmentCU',
          key: 'departmentCU',
          ellipsis: true,
          width: 200,
        },
        {
          title: '岗位类别',
          dataIndex: 'postType',
          key: 'postType',
          ellipsis: true,
          width: 80,
          render: (text) =>
            text ? getDictionaryLabel('postCategory', text) : text,
        },
        {
          title: '项目经理',
          dataIndex: 'pm',
          key: 'pm',
          ellipsis: true,
          width: 120,
        },
        {
          title: '当前状态',
          dataIndex: 'status',
          key: 'status',
          ellipsis: true,
          width: 80,
          align: 'center',
          render: (t) => (t === 1 ? '评定完成' : t === 0 ? <a>评定中</a> : ''),
        },
      ],
      //分页
      total: 0,
      pageSize: 10,
      page: 1,
      totalHistory: 0, //历史
      pageSizeHistory: 10, //历史
      pageHistory: 1, //历史
      pageSizeMy: 10,
      pageMy: 1,
      totalMy: 0,
      //数据
      tableData: [], //最新数据
      historyData: [], //历史数据
      myData: [],
      //表格列
      tableColumns: [
        {
          title: '工号',
          dataIndex: 'empNo',
          key: 'empNo',
          width: 120,
          fixed: 'left',
          ellipsis: true,
        },
        {
          title: '姓名',
          dataIndex: 'empName',
          key: 'empName',
          width: 100,
          ellipsis: true,
          fixed: 'left',
        },
        {
          title: '地域',
          dataIndex: 'regional',
          key: 'regional',
          ellipsis: true,
          width: 100,
        },
        {
          title: '部门BD',
          dataIndex: 'departmentBD',
          key: 'departmentBD',
          ellipsis: true,
          width: 270,
        },
        {
          title: '部门BU',
          dataIndex: 'departmentBU',
          key: 'departmentBU',
          ellipsis: true,
          width: 270,
        },
        {
          title: '部门CU',
          dataIndex: 'departmentCU',
          key: 'departmentCU',
          ellipsis: true,
          width: 270,
        },
        {
          title: '岗位类别',
          dataIndex: 'postType',
          key: 'postType',
          ellipsis: true,
          width: 80,
          render: (text) =>
            text ? getDictionaryLabel('postCategory', text) : text,
        },
        {
          title: '项目经理',
          dataIndex: 'pm',
          key: 'pm',
          ellipsis: true,
          width: 80,
        },
        {
          title: '是否发布',
          dataIndex: 'isPass',
          key: 'isPass',
          ellipsis: true,
          width: 80,
          align: 'center',
          render: (t) => (t === 1 ? '已发布' : t === 0 ? '未发布' : ''),
        },
        {
          title: '当前状态',
          dataIndex: 'status',
          key: 'status',
          ellipsis: true,
          width: 80,
          align: 'center',
          render: (t) => (t === 1 ? '评定完成' : t === 0 ? <a>评定中</a> : ''),
        },
        {
          title: '评定结果',
          dataIndex: 'reviewResult',
          key: 'reviewResult',
          ellipsis: true,
          width: 90,
          align: 'center',
          render: (t) =>
            t === 0 ? (
              <Tag color="#f50">未通过</Tag>
            ) : t === 1 ? (
              <Tag color="#87d068">通过</Tag>
            ) : (
              ''
            ),
        },
        {
          title: '评定时间',
          dataIndex: 'reviewTime',
          key: 'reviewTime',
          ellipsis: true,
          width: 100,
          render: (t) => this.getDate(t, 'ymd'),
        },
        {
          title: '评审计划结束时间',
          dataIndex: 'planEndTime',
          key: 'planEndTime',
          ellipsis: true,
          width: 140,
          render: (t) => this.getDate(t, 'ymd'),
        },
        {
          title: '评定人',
          dataIndex: 'reviewEmpName',
          key: 'reviewEmpName',
          ellipsis: true,
          width: 100,
        },
        {
          title: '评定次数',
          dataIndex: 'reviewTimes',
          key: 'reviewTimes',
          ellipsis: true,
          width: 80,
          align: 'center',
        },
        {
          title: '评审任务发起人',
          dataIndex: 'createEmpName',
          key: 'createEmpName',
          ellipsis: true,
          width: 130,
        },
        {
          title: '评审任务发起时间',
          dataIndex: 'createTime',
          key: 'createTime',
          ellipsis: true,
          width: 140,
          render: (t) => this.getDate(t, 'ymd'),
        },
        {
          title: '修改时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
          ellipsis: true,
          width: 150,
          render: (t) => this.getDate(t, 'hms'),
        },
        {
          title: '修改人',
          dataIndex: 'updateEmpName',
          key: 'updateEmpName',
          ellipsis: true,
          width: 100,
        },
        {
          title: '操作',
          dataIndex: 'handle',
          ellipsis: true,
          width: 60,
          fixed: 'right',
          align: 'center',
          render: (_, record) => (
            <Tooltip title="设置发布状态">
              <div style={{ width: 40 }}>
                <HasPermi
                  bottonData={{
                    type: 'link',
                    interceptor: 'tmfs:review:publishStatus',
                    clickFn: () => this.showModal('publish', record),
                    icon: <EditOutlined />,
                  }}
                />
              </div>
            </Tooltip>
          ),
        },
      ],
      tableColumnsMy: [
        {
          title: '工号',
          dataIndex: 'empNo',
          key: 'empNo',
          width: 120,
          fixed: 'left',
          ellipsis: true,
        },
        {
          title: '姓名',
          dataIndex: 'empName',
          key: 'empName',
          width: 140,
          ellipsis: true,
          fixed: 'left',
        },
        {
          title: '地域',
          dataIndex: 'regional',
          key: 'regional',
          ellipsis: true,
          width: 100,
        },
        {
          title: '部门BD',
          dataIndex: 'departmentBD',
          key: 'departmentBD',
          ellipsis: true,
          width: 270,
        },
        {
          title: '部门BU',
          dataIndex: 'departmentBU',
          key: 'departmentBU',
          ellipsis: true,
          width: 270,
        },
        {
          title: '部门CU',
          dataIndex: 'departmentCU',
          key: 'departmentCU',
          ellipsis: true,
          width: 270,
        },
        {
          title: '岗位类别',
          dataIndex: 'postType',
          key: 'postType',
          ellipsis: true,
          width: 80,
          render: (text) =>
            text ? getDictionaryLabel('postCategory', text) : text,
        },
        {
          title: '项目经理',
          dataIndex: 'pm',
          key: 'pm',
          ellipsis: true,
          width: 80,
        },
        {
          title: '是否发布',
          dataIndex: 'isPass',
          key: 'isPass',
          ellipsis: true,
          width: 80,
          align: 'center',
          render: (t) => (t === 1 ? '已发布' : t === 0 ? '未发布' : ''),
        },
        {
          title: '当前状态',
          dataIndex: 'status',
          key: 'status',
          ellipsis: true,
          width: 80,
          align: 'center',
          render: (t) => (t === 1 ? '评定完成' : t === 0 ? <a>评定中</a> : ''),
        },
        {
          title: '评定结果',
          dataIndex: 'reviewResult',
          key: 'reviewResult',
          ellipsis: true,
          width: 90,
          align: 'center',
          render: (t) =>
            t === 0 ? (
              <Tag color="#f50">未通过</Tag>
            ) : t === 1 ? (
              <Tag color="#87d068">通过</Tag>
            ) : (
              ''
            ),
        },
        {
          title: '评定时间',
          dataIndex: 'reviewTime',
          key: 'reviewTime',
          ellipsis: true,
          width: 100,
          render: (t) => this.getDate(t, 'ymd'),
        },
        {
          title: '评审计划结束时间',
          dataIndex: 'planEndTime',
          key: 'planEndTime',
          ellipsis: true,
          width: 140,
          render: (t) => this.getDate(t, 'ymd'),
        },
        {
          title: '评定人',
          dataIndex: 'reviewEmpName',
          key: 'reviewEmpName',
          ellipsis: true,
          width: 100,
        },
        {
          title: '评定次数',
          dataIndex: 'reviewTimes',
          key: 'reviewTimes',
          ellipsis: true,
          width: 80,
          align: 'center',
        },
        {
          title: '评审任务发起人',
          dataIndex: 'createEmpName',
          key: 'createEmpName',
          ellipsis: true,
          width: 130,
        },
        {
          title: '评审任务发起时间',
          dataIndex: 'createTime',
          key: 'createTime',
          ellipsis: true,
          width: 140,
          render: (t) => this.getDate(t, 'ymd'),
        },
        {
          title: '修改时间',
          dataIndex: 'updateTime',
          key: 'updateTime',
          ellipsis: true,
          width: 150,
          render: (t) => this.getDate(t, 'hms'),
        },
        {
          title: '修改人',
          dataIndex: 'updateEmpName',
          key: 'updateEmpName',
          ellipsis: true,
          width: 100,
        },
      ],
      //查询条件
      searchData: {},
      searchDataHistory: {}, //历史
      searchDataMy: {},
      // 查询条件项配置
      searchForm: [
        {
          type: 'input',
          name: '工号',
          code: 'empNo',
          placeholder: '请输入员工工号',
          maxLength: 20,
        },
        {
          type: 'input',
          name: '姓名',
          code: 'empName',
          placeholder: '请输入员工姓名',
          maxLength: 20,
        },
        {
          type: 'select',
          name: '地域',
          code: 'regionNo',
          options: getDictionaryLabel('addressConfig'),
        },
        {
          type: 'cascader',
          name: '部门',
          code: 'dept',
          options: JSON.parse(
            localStorage.getItem('deptList')
              ? localStorage.getItem('deptList')
              : '[]'
          ),
        },
        {
          type: 'select',
          name: '评审状态',
          code: 'reviewStatus',
          options: getDictionaryLabel('reviewStatus'),
        },
      ],
      activeKey: '1',
      searchEmpInput: null,
      searchEmpColumns: [
        {
          title: '工号',
          dataIndex: 'empNo',
          key: 'empNo',
          width: 80,
          fixed: 'left',
          ellipsis: true,
        },
        {
          title: '姓名',
          dataIndex: 'empName',
          key: 'empName',
          width: 160,
          ellipsis: true,
          fixed: 'left',
        },
        {
          title: '地域',
          dataIndex: 'regional',
          key: 'regional',
          ellipsis: true,
          width: 100,
        },
        {
          title: '部门',
          dataIndex: 'orgName',
          key: 'orgName',
          ellipsis: true,
          width: 180,
        },
      ],
      searchSelectedRowKeys: [],
      searchSelectedRows: [],
      searchTotal: 0,
      searchCurrentPage: 1,
      searchLoading: false,
      empInfoList: [],
      isShowSearch: true,
    }
  }
  addForm = React.createRef() //新增评定表单
  setEmpForm = React.createRef() //设置评定人
  setTimeForm = React.createRef() //设置评定时间
  performForm = React.createRef() //执行评定
  searchForm = React.createRef()
  //时间戳转换
  getDate = (time, type) => {
    if (!time) return
    if (type === 'ymd') {
      return moment(time).format('YYYY-MM-DD')
    } else if (type === 'hms') {
      return moment(time).format('YYYY-MM-DD HH:mm:ss')
    }
  }
  //获取最新数据
  getData = () => {
    this.setState({
      lastLoading: true,
      selectedRowKeys: [],
      selectedRows: [],
    })
    let searchData = this.state.searchData
    let data = {}
    for (const key in searchData) {
      if (searchData[key] || searchData[key] === 0) {
        if (key === 'dept') {
          const orgType = confirmDeptByCode(
            searchData[key][searchData[key].length - 1]
          )
          if (orgType && orgType.type == 'cu') {
            data.orgCuNo = orgType.value
          } else if (orgType && orgType.type == 'bu') {
            data.orgBuNo = orgType.value
          } else if (orgType && orgType.type == 'bd') {
            data.orgBDNo = orgType.value
          }
        } else {
          data[key] = searchData[key]
        }
      }
    }
    searchReviewData(data)
      .then((res) => {
        if (res.data.code === 200) {
          let data = res.data.data
          for (let i = 0; i < data.length; i++) {
            data[i].key = i + 1
          }
          this.setState({
            total: data.length,
            tableData: data,
            lastLoading: false,
            selectedRowKeys: [],
            selectedRows: [],
          })
        } else {
          this.setState({ lastLoading: false })
          message.error(res.data.message || '数据获取失败')
        }
      })
      .catch((err) => {
        this.setState({ lastLoading: false })
        message.error('数据获取失败')
      })
  }
  //获取历史数据
  getHistoryData = () => {
    this.setState({
      historyLoading: true,
      selectedRowKeysHistory: [], //历史表格多选
      selectedRowsHistory: [],
    })
    let searchDataHistory = this.state.searchDataHistory
    let data = {}
    for (const key in searchDataHistory) {
      if (searchDataHistory[key] || searchDataHistory[key] === 0) {
        if (key === 'dept') {
          const orgType = confirmDeptByCode(
            searchDataHistory[key][searchDataHistory[key].length - 1]
          )
          if (orgType && orgType.type === 'cu') {
            data.orgCuNo = orgType.value
          } else if (orgType && orgType.type === 'bu') {
            data.orgBuNo = orgType.value
          } else if (orgType && orgType.type === 'bd') {
            data.orgBDNo = orgType.value
          }
        } else {
          data[key] = searchDataHistory[key]
        }
      }
    }
    data.limit = this.state.pageHistory
    data.pageSize = this.state.pageSizeHistory
    searchHistoryReviewData(data)
      .then((res) => {
        if (res.data.code === 200) {
          if (res.data.data.list) {
            let data = res.data.data.list
            let _key = 1
            for (const item of data) {
              _key++
              item.key = _key
              if (item.children.length > 0) {
                for (const i of item.children) {
                  _key++
                  i.key = _key
                }
              } else {
                delete item.children
              }
            }
            this.setState({
              totalHistory: res.data.data.total,
              historyData: data,
              historyLoading: false,
            })
          } else {
            this.setState({
              totalHistory: 0,
              historyData: [],
              historyLoading: false,
            })
          }
        } else {
          this.setState({ historyLoading: false })
          message.error(res.data.message || '历史数据获取失败')
        }
      })
      .catch((err) => {
        this.setState({ historyLoading: false })
        message.error('历史数据获取失败')
      })
  }
  getMyData = () => {
    this.setState({
      myLoading: true,
      selectedRowsMy: [],
      selectedRowKeysMy: [],
    })
    let searchDataMy = this.state.searchDataMy
    let data = {}
    for (const key in searchDataMy) {
      if (searchDataMy[key] || searchDataMy[key] === 0) {
        if (key === 'dept') {
          const orgType = confirmDeptByCode(
            searchDataMy[key][searchDataMy[key].length - 1]
          )
          if (orgType && orgType.type === 'cu') {
            data.orgCuNo = orgType.value
          } else if (orgType && orgType.type === 'bu') {
            data.orgBuNo = orgType.value
          } else if (orgType && orgType.type === 'bd') {
            data.orgBDNo = orgType.value
          }
        } else {
          data[key] = searchDataMy[key]
        }
      }
    }
    data.limit = this.state.pageMy
    data.pageSize = this.state.pageSizeMy
    searchMyReviewData(data)
      .then((res) => {
        if (res.data.code === 200) {
          let data = res.data.data.list
          this.setState({
            totalMy: res.data.data.total,
            myData: data,
            myLoading: false,
          })
        } else {
          this.setState({ myLoading: false })
          message.error(res.data.message || '历史数据获取失败')
        }
      })
      .catch((err) => {
        this.setState({ myLoading: false })
        message.error('历史数据获取失败')
      })
  }
  //选择行
  onSelectChange = (selectedRowKeys, selectedRows) => {
    this.setState({ selectedRowKeys, selectedRows })
  }
  onSelectChangeHistory = (selectedRowKeysHistory, selectedRowsHistory) => {
    this.setState({ selectedRowKeysHistory, selectedRowsHistory })
  }
  onSelectChangeMy = (selectedRowKeysMy, selectedRowsMy) => {
    this.setState({ selectedRowKeysMy, selectedRowsMy })
  }
  onSelectChangeAdd = (selectedRowKeysAdd, selectedRowsAdd) => {
    this.setState({ selectedRowKeysAdd, selectedRowsAdd })
  }
  //修改页数changePage
  changePage = (page, pageSize) => {
    this.setState({
      page,
      pageSize,
    })
  }
  changePageHistory = (pageHistory, pageSizeHistory) => {
    this.setState(
      {
        pageHistory,
        pageSizeHistory,
      },
      () => {
        this.getHistoryData()
      }
    )
  }
  changePageMy = (pageMy, pageSizeMy) => {
    this.setState(
      {
        pageMy,
        pageSizeMy,
      },
      () => {
        this.getMyData()
      }
    )
  }
  //搜索
  execSearch = (data) => {
    this.setState({ searchData: data, page: 1 }, () => {
      this.getData()
    })
  }
  execSearchHistory = (data) => {
    this.setState({ searchDataHistory: data, pageHistory: 1 }, () => [
      this.getHistoryData(),
    ])
  }
  execSearchMy = (data) => {
    this.setState({ searchDataMy: data, pageMy: 1 }, () => [this.getMyData()])
  }
  //设置按钮加载动画开关
  buttonLoading = (flag) => {
    this.setState({ confirmLoading: flag })
  }
  //隐藏模态框
  hiddenModal = () => {
    this.setState({
      addModalVisible: false, //新增的模态框
      deleteModalVisible: false, //删除的模态框
      setEmpModalVisible: false, //设置评定人模态框
      setTimeModalVisible: false, //设置评定时间
      performModalVisible: false, //执行评定
      publishModalVisible: false, //发布评定
      downloadModalVisible: false, //导出
      uploadModalVisible: false, //导入
      confirmLoading: false, //确认按钮异步等待
      downState: this.state.activeKey - 1,
      selectedRowsAdd: [],
      selectedRowKeysAdd: [],
      searchSelectedRowKeys: [],
      searchSelectedRows: [],
    })
  }
  //显示模态框
  showModal = (name, downState) => {
    if (
      name == 'add' ||
      name == 'delete' ||
      name == 'setEmp' ||
      name == 'setTime'
    ) {
      if (this.state.selectedRows.length <= 0) {
        message.warn('请从列表选择需要操作的员工')
        return
      }
    } else if (name == 'publish') {
      if (this.state.selectedRows.length <= 0 && !downState) {
        message.warn('请选择需要操作的员工')
        return
      }
    } else if (name == 'perform') {
      if (this.state.selectedRowsMy.length <= 0) {
        message.warn('请选择需要操作的员工')
        return
      }
    }
    this.setState({
      downState: downState,
      addModalVisible: name == 'add' ? true : false, //新增的模态框
      deleteModalVisible: name == 'delete' ? true : false, //删除的模态框
      setEmpModalVisible: name == 'setEmp' ? true : false, //设置评定人模态框
      setTimeModalVisible: name == 'setTime' ? true : false, //设置评定时间
      performModalVisible: name == 'perform' ? true : false, //执行评定
      publishModalVisible: name == 'publish' ? true : false, //发布评定
      downloadModalVisible: name == 'download' ? true : false, //导出
      uploadModalVisible: name == 'upload' ? true : false, //导入
    })
  }
  //创建评定
  add = () => {
    this.addForm.current.validateFields().then((values, error) => {
      if (error) return
      if (this.state.selectedRowsAdd.length <= 0) {
        message.warn('请从列表选择需要操作的员工')
        return
      }
      this.buttonLoading(true)
      let empNoList = []
      for (const key in this.state.selectedRowsAdd) {
        empNoList[key] = this.state.selectedRowsAdd[key].empNo
      }
      let data = this.addForm.current.getFieldsValue()
      data.empNoList = empNoList
      data.planEndTime = new Date(
        data.planEndTime.format('YYYY-MM-DD')
      ).getTime()
      data.reviewEmpName = data.reviewEmpNo.split(' | ')[1]
      data.reviewEmpNo = data.reviewEmpNo.split(' | ')[0]
      addReviewData(data)
        .then((res) => {
          if (res.data.code === 200) {
            message.success('创建评定任务成功')
            this.getData()
            this.hiddenModal()
          } else {
            this.buttonLoading(false)
            message.error(res.data.message || '创建评定任务失败')
          }
        })
        .catch((err) => {
          this.buttonLoading(false)
          message.error('创建评定任务失败')
        })
    })
  }
  //删除评定
  delete = () => {
    if (this.state.selectedRows.length <= 0) {
      message.warn('请从列表选择需要操作的员工')
      return
    }
    this.buttonLoading(true)
    let ids = []
    for (const key in this.state.selectedRows) {
      ids[key] = this.state.selectedRows[key].id
    }
    deleteReviewData(ids)
      .then((res) => {
        if (res.data.code === 200) {
          message.success('删除评定任务成功')
          this.getData()
          this.hiddenModal()
        } else {
          this.buttonLoading(false)
          message.error(res.data.message || '删除评定任务失败')
        }
      })
      .catch((err) => {
        this.buttonLoading(false)
        message.error('删除评定任务失败')
      })
  }
  //设置评定人
  setEmp = () => {
    this.setEmpForm.current.validateFields().then((v, error) => {
      if (error) return
      if (this.state.selectedRows.length <= 0) {
        message.warn('请从列表选择需要操作的员工')
        return
      }
      this.buttonLoading(true)
      let reviewEmpNo = this.setEmpForm.current.getFieldsValue().reviewEmpNo
      let ids = []
      for (const key in this.state.selectedRows) {
        ids[key] = this.state.selectedRows[key].id
      }
      let data = { ids, reviewEmpNo }
      data.reviewEmpName = data.reviewEmpNo.split(' | ')[1]
      data.reviewEmpNo = data.reviewEmpNo.split(' | ')[0]
      assignReviewData(data)
        .then((res) => {
          if (res.data.code === 200) {
            message.success('设置评定人成功')
            this.getData()
            this.hiddenModal()
          } else {
            this.buttonLoading(false)
            message.error(res.data.message || '设置评定人失败')
          }
        })
        .catch((err) => {
          this.buttonLoading(false)
          message.error('设置评定人失败')
        })
    })
  }
  //设置评定时间
  setTime = () => {
    this.setTimeForm.current.validateFields().then((v, error) => {
      if (error) return
      if (this.state.selectedRows.length <= 0) {
        message.warn('请从列表选择需要操作的员工')
        return
      }
      this.buttonLoading(true)
      let planEndTime = new Date(
        this.setTimeForm.current.getFieldsValue().plantime.format('YYYY-MM-DD')
      ).getTime()
      let ids = []
      for (const key in this.state.selectedRows) {
        ids[key] = this.state.selectedRows[key].id
      }
      let data = { ids, planEndTime }
      planEndTimeReviewData(data)
        .then((res) => {
          if (res.data.code === 200) {
            message.success('设置评定时间成功')
            this.getData()
            this.hiddenModal()
          } else {
            this.buttonLoading(false)
            message.error(res.data.message || '设置评定时间失败')
          }
        })
        .catch((err) => {
          this.buttonLoading(false)
          message.error('设置评定时间失败')
        })
    })
  }
  //执行评定
  perform = () => {
    this.performForm.current.validateFields().then((v, error) => {
      if (error) return
      this.buttonLoading(true)
      let data = this.performForm.current.getFieldsValue()
      let ids = []
      if (this.state.selectedRowsMy.length > 0) {
        for (const key in this.state.selectedRowsMy) {
          ids[key] = this.state.selectedRowsMy[key].id
        }
      } else {
        message.warn('请从列表选择需要评定的员工')
        return
      }
      data.ids = ids
      executeReviewData(data)
        .then((res) => {
          if (res.data.code === 200) {
            message.success('评定成功')
            this.getMyData()
            this.hiddenModal()
          } else {
            this.buttonLoading(false)
            message.error(res.data.message || '评定失败')
          }
        })
        .catch((err) => {
          this.buttonLoading(false)
          message.error('评定失败')
        })
    })
  }
  //设置发布状态
  publish = () => {
    if (this.state.selectedRows.length <= 0 && !this.state.downState) {
      message.warn('请从列表选择需要操作的员工')
      return
    }
    this.buttonLoading(true)
    let ids = []
    if (this.state.downState) {
      //右侧单条
      ids[0] = this.state.downState.id
    } else {
      //多条批量
      for (const key in this.state.selectedRows) {
        ids[key] = this.state.selectedRows[key].id
      }
    }
    let data = { ids, publishStatus: this.state.publishStatus }
    publishReviewData(data)
      .then((res) => {
        if (res.data.code === 200) {
          message.success('设置发布状态成功')
          if (this.state.activeKey == '1') {
            this.getData()
          } else if (this.state.activeKey == '2') {
            this.getHistoryData()
          }

          this.hiddenModal()
        } else {
          this.buttonLoading(false)
          message.error(res.data.message || '设置发布状态失败')
        }
      })
      .catch((err) => {
        this.buttonLoading(false)
        message.error('设置发布状态失败')
      })
  }
  //导出评定数据
  download = () => {
    this.buttonLoading(true)
    let data = {}
    let exportIdList = []
    let exportType = null
    if (
      !this.state.selectedRows.length &&
      !this.state.selectedRowsHistory.length
    ) {
      if (this.state.downState) {
        data.exportType = 2
        let searchData = this.state.searchDataHistory
        for (const key in searchData) {
          if (searchData[key] || searchData[key] === 0) {
            if (key === 'dept') {
              const orgType = confirmDeptByCode(
                searchData[key][searchData[key].length - 1]
              )
              if (orgType && orgType.type === 'cu') {
                data.orgCuNo = orgType.value
              } else if (orgType && orgType.type === 'bu') {
                data.orgBuNo = orgType.value
              } else if (orgType && orgType.type === 'bd') {
                data.orgBDNo = orgType.value
              }
            } else {
              data[key] = searchData[key]
            }
          }
        }
      } else {
        data.exportType = 1
        let searchData = this.state.searchData
        for (const key in searchData) {
          if (searchData[key] || searchData[key] === 0) {
            if (key === 'dept') {
              const orgType = confirmDeptByCode(
                searchData[key][searchData[key].length - 1]
              )
              if (orgType && orgType.type == 'cu') {
                data.orgCuNo = orgType.value
              } else if (orgType && orgType.type == 'bu') {
                data.orgBuNo = orgType.value
              } else if (orgType && orgType.type == 'bd') {
                data.orgBDNo = orgType.value
              }
            } else {
              data[key] = searchData[key]
            }
          }
        }
      }
    } else {
      if (this.state.downState) {
        for (const key in this.state.selectedRowsHistory) {
          if (this.state.selectedRowsHistory[key].id)
            exportIdList[key] = this.state.selectedRowsHistory[key].id
          exportType = 0
        }
      } else {
        for (const key in this.state.selectedRows) {
          if (this.state.selectedRows[key].id)
            exportIdList[key] = this.state.selectedRows[key].id
          exportType = 0
        }
      }
      data.exportIdList = exportIdList
      data.exportType = exportType
    }
    exportReviewData(data)
      .then((res) => {
        if (res.data.code === 200) {
          message.success('导出任务已建立，请在导入导出详情页面查看导出进展。')
          this.hiddenModal()
          this.buttonLoading(false)
        } else {
          message.error(res.data.message || '导出任务建立失败')
          this.buttonLoading(false)
        }
      })
      .catch((err) => {
        message.error('导出任务建立失败')
        this.buttonLoading(false)
      })
  }
  //导入评定数据
  upload = () => {
    this.buttonLoading(true)
  }
  downloadImportReviewModal = () => {
    downloadImportReviewModal()
      .then((response) => {
        if (response.status == 200) {
          const fileName = '评定管理导入模板.xlsx'
          const blob = new Blob([response.data], {
            type: 'application/octet-stream',
          })
          if (typeof window.navigator.msSaveBlob !== 'undefined') {
            window.navigator.msSaveBlob(blob, decodeURI(fileName))
          } else {
            const blobURL = window.URL.createObjectURL(blob)
            const tempLink = document.createElement('a')
            tempLink.style.display = 'none'
            tempLink.href = blobURL
            tempLink.setAttribute('download', decodeURI(fileName))
            if (typeof tempLink.download === 'undefined') {
              tempLink.setAttribute('target', '_blank')
            }
            document.body.appendChild(tempLink)
            tempLink.click()
            document.body.removeChild(tempLink)
            window.URL.revokeObjectURL(blobURL)
            message.success('模板下载成功')
          }
        } else {
          message.error(response.data.message || '模板下载失败')
        }
      })
      .catch((err) => {
        message.error('模板下载失败')
      })
  }
  //修改文件
  fileChange = (info) => {
    const { status } = info.file
    if (status !== 'uploading') {
    }
    if (status === 'done') {
      message.success(`${info.file.name} 文件上传成功.`)
    } else if (status === 'error') {
      message.error(`${info.file.name} 文件上传失败.`)
    }
  }
  tabChange = (key) => {
    this.setState({
      activeKey: key,
      searchData: [],
      searchDataHistory: [],
      searchDataMy: [],
      selectedRowKeys: [], //最新表格多选
      selectedRows: [],
      selectedRowKeysHistory: [], //历史表格多选
      selectedRowsHistory: [],
      selectedRowsMy: [],
      selectedRowKeysMy: [],
      total: 0,
      pageSize: 10,
      page: 1,
      totalHistory: 0, //历史
      pageSizeHistory: 10, //历史
      pageHistory: 1, //历史
      pageSizeMy: 10,
      pageMy: 1,
      totalMy: 0,
    })
    if (key == '2') {
      this.getHistoryData()
    } else if (key == '3') {
      this.getMyData()
    } else if (key == '1') {
      this.getData()
    }
  }
  //专家信息全查
  searchExpertInfo = () => {
    let data = { pageSize: 1000, currentPage: 1 }
    searchExpertList(data)
      .then((res) => {
        if (res.data.code === 200 && res.data.data) {
          if (res.data.data.list.length > 0) {
            res.data.data.list.forEach((item) => {
              item.orgName = item.orgCuName || item.orgBuName || item.orgBdName
            })
            this.setState({
              empInfoList: res.data.data.list,
            })
          } else {
            this.setState({ empInfoList: [] })
          }
        } else {
          this.setState({ empInfoList: [] })
        }
      })
      .catch((err) => {
        console.log(err)
      })
  }
  componentWillMount() {
    const list = JSON.parse(
      localStorage.getItem('deptList') ? localStorage.getItem('deptList') : '[]'
    )
    if (list.length === 0) {
      this.setState(
        {
          isShowSearch: false,
          searchForm: [
            {
              type: 'input',
              name: '工号',
              code: 'empNo',
              placeholder: '请输入员工工号',
              maxLength: 20,
            },
            {
              type: 'input',
              name: '姓名',
              code: 'empName',
              placeholder: '请输入员工姓名',
              maxLength: 20,
            },
            {
              type: 'select',
              name: '评审状态',
              code: 'reviewStatus',
              options: getDictionaryLabel('reviewStatus'),
            },
          ],
        },
        () => {
          //获取表单数据
          this.getMyData()
        }
      )
    } else {
      this.getData()
    }
    this.searchExpertInfo()
  }
  componentDidMount() {}
  //组件销毁时取消setState
  componentWillUnmount() {
    this.setState = (state, callback) => {
      return
    }
  }
  render() {
    //多选行配置
    const rowSelection = {
      selectedRowKeys: this.state.selectedRowKeys,
      onChange: this.onSelectChange,
    }
    const rowSelectionHistory = {
      selectedRowKeys: this.state.selectedRowKeysHistory,
      onChange: this.onSelectChangeHistory,
    }
    const rowSelectionMy = {
      selectedRowKeys: this.state.selectedRowKeysMy,
      onChange: this.onSelectChangeMy,
    }
    const rowSelectionAdd = {
      selectedRowKeys: this.state.selectedRowKeysAdd,
      onChange: this.onSelectChangeAdd,
    }
    const authToken = window.localStorage.getItem('authToken')
    const token = window.localStorage.getItem('refreshToken')
    const url = getAjaxurl() + '/tmfs/review/import/async'
    const importProps = {
      action: url,
      name: 'file',
      accept: '.xlsx',
      headers: {
        refreshToken: token,
        authToken: authToken,
      },
      onChange(info) {
        const { status } = info.file
        if (status !== 'uploading') {
        }
        if (status === 'done') {
          if (info.file.response.code == 200) {
            message.success(
              `创建导入任务成功，请稍后在导入导出结果页面查看数据`
            )
          } else if (info.file.response.code == 500) {
            message.error(info.file.response.message || `创建导入任务失败`)
          } else {
            message.error(`创建导入任务失败`)
          }
        } else if (status === 'error') {
          message.error(`${info.file.name}  上传失败`)
        }
      },
    }
    if (this.state.isShowSearch) {
      return (
        <div id="evaluate">
          <div className="myProjectsBody">
            <Tabs onChange={this.tabChange}>
              <Tabs.TabPane tab="最新评定信息" key="1">
                <div className="bigContent2">
                  <AdvancedSearchForm
                    execSearch={this.execSearch}
                    formData={this.state.searchForm}
                  />
                </div>
                <div className="segmentationDiv"></div>
                <div className="tabstyle">
                  <div className="bigContent1">
                    <div className="operatingDiv">
                      <Row justify="space-between">
                        <Col lg={18} md={24} sm={24} xs={24}>
                          <Space size={0}>
                            {this.state.bottonListLeft.map((item) => (
                              <HasPermi
                                key={item.interceptor}
                                bottonData={item}
                              />
                            ))}
                          </Space>
                          {/* <Space size={0} style={{ marginLeft: 10 }}>
                            {this.state.bottonListMiddle.map((item) => (
                              <HasPermi
                                key={item.interceptor}
                                bottonData={item}
                              />
                            ))}
                          </Space> */}
                        </Col>
                        <Col
                          lg={6}
                          md={24}
                          sm={24}
                          xs={24}
                          style={{ textAlign: 'right' }}
                        >
                          <Space size={0}>
                            {this.state.bottonListRight.map((item) => (
                              <HasPermi
                                key={item.interceptor}
                                bottonData={item}
                              />
                            ))}
                          </Space>
                        </Col>
                      </Row>
                    </div>
                    <div className="tableDiff">
                      <Table
                        loading={this.state.lastLoading}
                        style={{ marginTop: 10 }}
                        scroll={{ x: '100' }}
                        rowSelection={{ type: 'checkbox', ...rowSelection }}
                        columns={this.state.tableColumns}
                        dataSource={this.state.tableData}
                        pagination={{
                          total: this.state.total,
                          pageSize: this.state.pageSize,
                          current: this.state.page,
                          showSizeChanger: true,
                          onChange: this.changePage,
                          onShowSizeChange: this.changePageSize,
                          showTotal: (total) => '共 ' + total + ' 条',
                        }}
                        bordered
                      />
                    </div>
                  </div>
                </div>
              </Tabs.TabPane>

              <Tabs.TabPane tab="历史评定信息" key="2">
                <div className="bigContent2">
                  <AdvancedSearchForm
                    execSearch={this.execSearchHistory}
                    formData={this.state.searchForm}
                  />
                </div>
                <div className="segmentationDiv"></div>
                <div className="tabstyle">
                  <div className="bigContent1">
                    <div className="operatingDiv">
                      <Row justify="space-between">
                        <Col span={24} style={{ textAlign: 'right' }}>
                          <HasPermi
                            bottonData={{
                              interceptor: 'tmfs:review:export',
                              clickFn: () => this.showModal('download', 1),
                              icon: <DownloadOutlined />,
                              text: '导出',
                            }}
                          />
                        </Col>
                      </Row>
                    </div>
                    <div className="tableDiff">
                      <Table
                        indentSize={0}
                        loading={this.state.historyLoading}
                        scroll={{ x: '100' }}
                        style={{ marginTop: 10 }}
                        rowSelection={{
                          type: 'checkbox',
                          ...rowSelectionHistory,
                        }}
                        columns={this.state.tableColumns}
                        dataSource={this.state.historyData}
                        pagination={{
                          total: this.state.totalHistory,
                          pageSize: this.state.pageSizeHistory,
                          current: this.state.pageHistory,
                          showSizeChanger: true,
                          onChange: this.changePageHistory,
                          showTotal: (totalHistory) =>
                            '共 ' + totalHistory + ' 条',
                        }}
                        bordered
                      />
                    </div>
                  </div>
                </div>
              </Tabs.TabPane>

              <Tabs.TabPane tab="我的评定任务" key="3">
                <div className="bigContent1">
                  <AdvancedSearchForm
                    execSearch={this.execSearchMy}
                    formData={this.state.searchForm}
                  />
                </div>
                <div className="segmentationDiv"></div>
                <div className="tabstyle">
                  <div className="bigContent1">
                    <div className="operatingDiv">
                      <Row justify="space-between">
                        <Col span={24}>
                          <Space size={0}>
                            <Button
                              type="ghost"
                              onClick={() => this.showModal('perform')}
                            >
                              执行评定
                            </Button>
                            {/* {this.state.bottonListMy.map((item) => (
                              <HasPermi
                                key={item.interceptor}
                                bottonData={item}
                              />
                            ))} */}
                          </Space>
                        </Col>
                      </Row>
                    </div>
                    <div className="tableDiff">
                      <Table
                        rowKey="id"
                        loading={this.state.myLoading}
                        style={{ marginTop: 10 }}
                        scroll={{ x: '100' }}
                        rowSelection={{ type: 'checkbox', ...rowSelectionMy }}
                        columns={this.state.tableColumnsMy}
                        dataSource={this.state.myData}
                        pagination={{
                          total: this.state.totalMy,
                          pageSize: this.state.pageSizeMy,
                          current: this.state.pageMy,
                          showSizeChanger: true,
                          onChange: this.changePageMy,
                          showTotal: (total) => '共 ' + total + ' 条',
                        }}
                        bordered
                      />
                    </div>
                  </div>
                </div>
              </Tabs.TabPane>
            </Tabs>
          </div>
          {/* 新增 */}
          <NewModal
            modalOptions={{
              width: '900px',
              title: '创建评定任务',
              destroyOnClose: true,
              visible: this.state.addModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.add,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form name="addForm" ref={this.addForm} labelAlign="left">
              <Form.Item>
                <Table
                  scroll={{ y: '400px' }}
                  rowSelection={{ type: 'checkbox', ...rowSelectionAdd }}
                  columns={this.state.addColumns}
                  dataSource={this.state.selectedRows}
                  size="small"
                  bordered
                  pagination={false}
                />
              </Form.Item>
              <Row>
                <Col span={10}>
                  <Form.Item
                    label="评审计划结束时间"
                    name="planEndTime"
                    rules={[{ required: true, message: '请选择日期' }]}
                  >
                    <DatePicker
                      format="YYYY-MM-DD"
                      style={{ width: '100%' }}
                      disabledDate={(current) => {
                        return current < moment().subtract(1, 'day')
                      }}
                    ></DatePicker>
                  </Form.Item>
                </Col>
                <Col span={12} offset={1}>
                  <Form.Item
                    label="评定人"
                    name="reviewEmpNo"
                    rules={[{ required: true, message: '请选择评定人' }]}
                  >
                    <Select
                      style={{ width: 359 }}
                      showSearch
                      optionFilterProp="children"
                      filterOption={(input, option) =>
                        option.children
                          .toLowerCase()
                          .indexOf(input.toLowerCase()) >= 0
                      }
                      placeholder="请选择评定人"
                    >
                      {this.state.empInfoList.map((item) => {
                        return (
                          <Select.Option
                            key={item.empNo}
                            value={
                              item.empNo +
                              ' | ' +
                              item.empName +
                              ' | ' +
                              item.orgName
                            }
                          >
                            {item.empNo +
                              ' | ' +
                              item.empName +
                              ' | ' +
                              item.orgName}
                          </Select.Option>
                        )
                      })}
                    </Select>
                  </Form.Item>
                </Col>
              </Row>
            </Form>
            {/* {SearchExpert()} */}
          </NewModal>
          {/* 删除 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '删除提示',
              visible: this.state.deleteModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'right',
              btnList: [
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
                {
                  key: 0,
                  onClick: this.delete,
                  text: '确认删除',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
              ],
            }}
          >
            <DeleteFilled
              style={{
                fontSize: '28px',
                color: '#e00',
                float: 'left',
                backgroundColor: '#f002',
                padding: 8,
                borderRadius: '50%',
              }}
            />
            <div
              style={{
                fontSize: 14,
                marginLeft: 60,
                fontWeight: 700,
                height: 44,
                lineHeight: '44px',
              }}
            >
              即将取消排评审任务，请确认！
            </div>
          </NewModal>
          {/* 设置评定人 */}
          <NewModal
            modalOptions={{
              width: '500px',
              title: '设置评定人',
              destroyOnClose: true,
              visible: this.state.setEmpModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.setEmp,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form name="setEmpForm" ref={this.setEmpForm}>
              <Form.Item
                label="评定人"
                name="reviewEmpNo"
                rules={[{ required: true, message: '请选择评定人' }]}
              >
                <Select
                  showSearch
                  optionFilterProp="children"
                  filterOption={(input, option) =>
                    option.children
                      .toLowerCase()
                      .indexOf(input.toLowerCase()) >= 0
                  }
                  style={{ width: 385 }}
                  placeholder="请选择评定人"
                >
                  {this.state.empInfoList.map((item) => {
                    return (
                      <Select.Option
                        key={item.empNo}
                        value={
                          item.empNo +
                          ' | ' +
                          item.empName +
                          ' | ' +
                          item.orgName
                        }
                      >
                        {item.empNo +
                          ' | ' +
                          item.empName +
                          ' | ' +
                          item.orgName}
                      </Select.Option>
                    )
                  })}
                </Select>
              </Form.Item>
            </Form>
            {/* {SearchExpert()} */}
          </NewModal>
          {/* 设置评定时间 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '设置评定时间',
              destroyOnClose: true,
              visible: this.state.setTimeModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.setTime,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form name="setTimeForm" ref={this.setTimeForm} labelAlign="left">
              <Form.Item
                label="评定时间"
                name="plantime"
                rules={[{ required: true, message: '请选择日期' }]}
              >
                <DatePicker
                  style={{ width: '100%' }}
                  disabledDate={(current) => {
                    return current < moment().subtract(1, 'day')
                  }}
                ></DatePicker>
              </Form.Item>
            </Form>
          </NewModal>
          {/* 执行评定 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '执行评定',
              destroyOnClose: true,
              visible: this.state.performModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.perform,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form
              name="perform"
              ref={this.performForm}
              labelAlign="right"
              labelCol={{ span: 6, offset: 0 }}
            >
              <Form.Item
                label="当前状态"
                name="status"
                rules={[{ required: true, message: '请设置当前状态' }]}
              >
                <Radio.Group
                  options={[
                    { label: '评定完成', value: '1' },
                    { label: '评定中', value: '0' },
                  ]}
                />
              </Form.Item>
              <Form.Item
                label="评定结果"
                name="result"
                rules={[{ required: true, message: '请设置评定结果' }]}
              >
                <Radio.Group
                  options={[
                    { label: '通过', value: '1' },
                    { label: '未通过', value: '0' },
                  ]}
                />
              </Form.Item>
              <Form.Item
                label="评审意见"
                name="comment"
                rules={[{ max: 50, message: '不能超过50字' }]}
              >
                <Input.TextArea
                  maxLength={50}
                  rows={4}
                  placeholder="请输入"
                ></Input.TextArea>
              </Form.Item>
            </Form>
          </NewModal>
          {/* 发布评定 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '设置发布状态',
              destroyOnClose: true,
              visible: this.state.publishModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.publish,
                  text: this.state.publishStatus ? '确认发布' : '取消发布',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            设置发布状态：
            <Radio.Group
              onChange={(e) => {
                this.setState({ publishStatus: e.target.value })
              }}
              value={this.state.publishStatus}
            >
              <Radio value={0}>否</Radio>
              <Radio value={1}>是</Radio>
            </Radio.Group>
          </NewModal>
          {/* 导出 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '导出评定数据',
              visible: this.state.downloadModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.download,
                  text: this.state.confirmLoading ? '正在导出' : '确认导出',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <div>
              {!this.state.selectedRows.length &&
              !this.state.selectedRowsHistory.length
                ? '确认导出全部评定信息？'
                : '确认导出选中的评定信息？'}
            </div>
          </NewModal>
          {/* 导入 */}
          <NewModal
            modalOptions={{
              width: '500px',
              title: '导入评定数据',
              visible: this.state.uploadModalVisible,
              onCancel: this.hiddenModal,
              destroyOnClose: true,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '关闭',
                },
              ],
            }}
          >
            <Upload.Dragger {...importProps}>
              <p className="ant-upload-drag-icon">
                <InboxOutlined />
              </p>
              <p className="ant-upload-text">单击或拖动文件到该区域进行上传</p>
              <p className="ant-upload-hint">
                一次只能导入单个文件，单次最大限制
                <span style={{ color: 'red' }}>1000</span>行。仅支持
                <span style={{ color: 'red' }}>.xlsx</span>
                格式
              </p>
            </Upload.Dragger>
            <Button type="link" onClick={this.downloadImportReviewModal}>
              下载导入模板
            </Button>
          </NewModal>
        </div>
      )
    } else {
      return (
        <div id="evaluate">
          <div className="myProjectsBody">
            <Tabs onChange={this.tabChange}>
              <Tabs.TabPane tab="我的评定任务" key="3">
                <div className="bigContent1">
                  <AdvancedSearchForm
                    execSearch={this.execSearchMy}
                    formData={this.state.searchForm}
                  />
                </div>
                <div className="segmentationDiv"></div>
                <div className="tabstyle">
                  <div className="bigContent1">
                    <div className="operatingDiv">
                      <Row justify="space-between">
                        <Col span={24}>
                          <Space size={0}>
                            <Button
                              type="ghost"
                              onClick={() => this.showModal('perform')}
                            >
                              执行评定
                            </Button>
                            {/* {this.state.bottonListMy.map((item) => (
                              <HasPermi
                                key={item.interceptor}
                                bottonData={item}
                              />
                            ))} */}
                          </Space>
                        </Col>
                      </Row>
                    </div>
                    <div className="tableDiff">
                      <Table
                        rowKey="id"
                        loading={this.state.myLoading}
                        style={{ marginTop: 10 }}
                        scroll={{ x: '100' }}
                        rowSelection={{ type: 'checkbox', ...rowSelectionMy }}
                        columns={this.state.tableColumnsMy}
                        dataSource={this.state.myData}
                        pagination={{
                          total: this.state.totalMy,
                          pageSize: this.state.pageSizeMy,
                          current: this.state.pageMy,
                          showSizeChanger: true,
                          onChange: this.changePageMy,
                          showTotal: (total) => '共 ' + total + ' 条',
                        }}
                        bordered
                      />
                    </div>
                  </div>
                </div>
              </Tabs.TabPane>
            </Tabs>
          </div>
          {/* 新增 */}
          <NewModal
            modalOptions={{
              width: '900px',
              title: '创建评定任务',
              destroyOnClose: true,
              visible: this.state.addModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.add,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form name="addForm" ref={this.addForm} labelAlign="left">
              <Form.Item>
                <Table
                  scroll={{ y: '400px' }}
                  rowSelection={{ type: 'checkbox', ...rowSelectionAdd }}
                  columns={this.state.addColumns}
                  dataSource={this.state.selectedRows}
                  size="small"
                  bordered
                  pagination={false}
                />
              </Form.Item>
              <Row>
                <Col span={10}>
                  <Form.Item
                    label="评审计划结束时间"
                    name="planEndTime"
                    rules={[{ required: true, message: '请选择日期' }]}
                  >
                    <DatePicker
                      format="YYYY-MM-DD"
                      style={{ width: '100%' }}
                      disabledDate={(current) => {
                        return current < moment().subtract(1, 'day')
                      }}
                    ></DatePicker>
                  </Form.Item>
                </Col>
                <Col span={12} offset={1}>
                  <Form.Item
                    label="评定人"
                    name="reviewEmpNo"
                    rules={[{ required: true, message: '请选择评定人' }]}
                  >
                    <Select
                      style={{ width: 359 }}
                      showSearch
                      optionFilterProp="children"
                      filterOption={(input, option) =>
                        option.children
                          .toLowerCase()
                          .indexOf(input.toLowerCase()) >= 0
                      }
                      placeholder="请选择评定人"
                    >
                      {this.state.empInfoList.map((item) => {
                        return (
                          <Select.Option
                            key={item.empNo}
                            value={
                              item.empNo +
                              ' | ' +
                              item.empName +
                              ' | ' +
                              item.orgName
                            }
                          >
                            {item.empNo +
                              ' | ' +
                              item.empName +
                              ' | ' +
                              item.orgName}
                          </Select.Option>
                        )
                      })}
                    </Select>
                  </Form.Item>
                </Col>
              </Row>
            </Form>
            {/* {SearchExpert()} */}
          </NewModal>
          {/* 删除 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '删除提示',
              visible: this.state.deleteModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'right',
              btnList: [
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
                {
                  key: 0,
                  onClick: this.delete,
                  text: '确认删除',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
              ],
            }}
          >
            <DeleteFilled
              style={{
                fontSize: '28px',
                color: '#e00',
                float: 'left',
                backgroundColor: '#f002',
                padding: 8,
                borderRadius: '50%',
              }}
            />
            <div
              style={{
                fontSize: 14,
                marginLeft: 60,
                fontWeight: 700,
                height: 44,
                lineHeight: '44px',
              }}
            >
              即将取消排评审任务，请确认！
            </div>
          </NewModal>
          {/* 设置评定人 */}
          <NewModal
            modalOptions={{
              width: '500px',
              title: '设置评定人',
              destroyOnClose: true,
              visible: this.state.setEmpModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.setEmp,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form name="setEmpForm" ref={this.setEmpForm}>
              <Form.Item
                label="评定人"
                name="reviewEmpNo"
                rules={[{ required: true, message: '请选择评定人' }]}
              >
                <Select
                  showSearch
                  optionFilterProp="children"
                  filterOption={(input, option) =>
                    option.children
                      .toLowerCase()
                      .indexOf(input.toLowerCase()) >= 0
                  }
                  style={{ width: 385 }}
                  placeholder="请选择评定人"
                >
                  {this.state.empInfoList.map((item) => {
                    return (
                      <Select.Option
                        key={item.empNo}
                        value={
                          item.empNo +
                          ' | ' +
                          item.empName +
                          ' | ' +
                          item.orgName
                        }
                      >
                        {item.empNo +
                          ' | ' +
                          item.empName +
                          ' | ' +
                          item.orgName}
                      </Select.Option>
                    )
                  })}
                </Select>
              </Form.Item>
            </Form>
            {/* {SearchExpert()} */}
          </NewModal>
          {/* 设置评定时间 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '设置评定时间',
              destroyOnClose: true,
              visible: this.state.setTimeModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.setTime,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form name="setTimeForm" ref={this.setTimeForm} labelAlign="left">
              <Form.Item
                label="评定时间"
                name="plantime"
                rules={[{ required: true, message: '请选择日期' }]}
              >
                <DatePicker
                  style={{ width: '100%' }}
                  disabledDate={(current) => {
                    return current < moment().subtract(1, 'day')
                  }}
                ></DatePicker>
              </Form.Item>
            </Form>
          </NewModal>
          {/* 执行评定 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '执行评定',
              destroyOnClose: true,
              visible: this.state.performModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.perform,
                  text: '确认',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <Form
              name="perform"
              ref={this.performForm}
              labelAlign="right"
              labelCol={{ span: 6, offset: 0 }}
            >
              <Form.Item
                label="当前状态"
                name="status"
                rules={[{ required: true, message: '请设置当前状态' }]}
              >
                <Radio.Group
                  options={[
                    { label: '评定完成', value: '1' },
                    { label: '评定中', value: '0' },
                  ]}
                />
              </Form.Item>
              <Form.Item
                label="评定结果"
                name="result"
                rules={[{ required: true, message: '请设置评定结果' }]}
              >
                <Radio.Group
                  options={[
                    { label: '通过', value: '1' },
                    { label: '未通过', value: '0' },
                  ]}
                />
              </Form.Item>
              <Form.Item
                label="评审意见"
                name="comment"
                rules={[{ max: 50, message: '不能超过50字' }]}
              >
                <Input.TextArea
                  maxLength={50}
                  rows={4}
                  placeholder="请输入"
                ></Input.TextArea>
              </Form.Item>
            </Form>
          </NewModal>
          {/* 发布评定 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '设置发布状态',
              destroyOnClose: true,
              visible: this.state.publishModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.publish,
                  text: this.state.publishStatus ? '确认发布' : '取消发布',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            设置发布状态：
            <Radio.Group
              onChange={(e) => {
                this.setState({ publishStatus: e.target.value })
              }}
              value={this.state.publishStatus}
            >
              <Radio value={0}>否</Radio>
              <Radio value={1}>是</Radio>
            </Radio.Group>
          </NewModal>
          {/* 导出 */}
          <NewModal
            modalOptions={{
              width: '400px',
              title: '导出评定数据',
              visible: this.state.downloadModalVisible,
              onCancel: this.hiddenModal,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 0,
                  onClick: this.download,
                  text: this.state.confirmLoading ? '正在导出' : '确认导出',
                  type: 'primary',
                  loading: this.state.confirmLoading,
                },
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '取消',
                },
              ],
            }}
          >
            <div>
              {!this.state.selectedRows.length &&
              !this.state.selectedRowsHistory.length
                ? '确认导出全部评定信息？'
                : '确认导出选中的评定信息？'}
            </div>
          </NewModal>
          {/* 导入 */}
          <NewModal
            modalOptions={{
              width: '500px',
              title: '导入评定数据',
              visible: this.state.uploadModalVisible,
              onCancel: this.hiddenModal,
              destroyOnClose: true,
            }}
            buttonOptions={{
              position: 'center',
              btnList: [
                {
                  key: 1,
                  onClick: this.hiddenModal,
                  text: '关闭',
                },
              ],
            }}
          >
            <Upload.Dragger {...importProps}>
              <p className="ant-upload-drag-icon">
                <InboxOutlined />
              </p>
              <p className="ant-upload-text">单击或拖动文件到该区域进行上传</p>
              <p className="ant-upload-hint">
                一次只能导入单个文件，单次最大限制
                <span style={{ color: 'red' }}>1000</span>行。仅支持
                <span style={{ color: 'red' }}>.xlsx</span>
                格式
              </p>
            </Upload.Dragger>
            <Button type="link" onClick={this.downloadImportReviewModal}>
              下载导入模板
            </Button>
          </NewModal>
        </div>
      )
    }
  }
}
export default Index
